const { ccclass, property } = cc._decorator;

import o from "./AudioManager"
import i from "./EngineUtil"
import r from "./frameworkManager"
import n, { SkillType } from "./MatchGameData"
import l from "./MatchGameConfig"
import s, { ObstacleAllType } from "./ObstacleConfig"
@ccclass
class MatchGameAudioMgr {


    private static _instance: MatchGameAudioMgr;

    public static getInstance(): MatchGameAudioMgr {
        if (!this._instance) {
            this._instance = new MatchGameAudioMgr();
        }
        return this._instance;
    }

    public playMusic(e, t?, a?, i?, r?) {
        void 0 === t && (t = false);
        void 0 === a && (a = false);
        void 0 === r && (r = false);
        o.getInstance().playMusic(e, t, a, i, true);
    }

    public playMusicSingle(e, t?, a?, i?, r?) {
        void 0 === t && (t = false);
        void 0 === a && (a = false);
        void 0 === r && (r = false);
        o.getInstance().playMusic(e, t, a, i, false);
    }

    public stopMusic(e, t?) {
        void 0 === t && (t = false);
        o.getInstance().stopMusic(e, t);
    }

    public playSquareDownAudio(e) {
        if (!n.skipEndGameReplacement && e !== 0) {
            var t = e > 0 ? "fall_hit_1" : "fall_hit_2";
            this.playMusic(t);
        }
    }

    public playChangeAndio(e) {
        var t = e ? "wrong_move" : "match_item_swipe";
        this.playMusic(t);
    }

    public playPropCreationAudio(e) {
        if (!n.skipEndGameReplacement && !n.skipEndGameReplacement) {
            var t;
            if (e === l.PropType.RocketHorzontall || e === l.PropType.RocketVertial) {
                t = "rocket_creation";
            } else if (e === l.PropType.Tnt) {
                t = "tnt_creation";
            } else if (e === l.PropType.Propeller) {
                t = "propeller_creation";
            } else if (e === l.PropType.LightingBall) {
                t = "lightball_creation";
            } else {
                t = "match_explode" + i.getRandomNum(1, 6);
            }
            this.playMusic(t);
        }
    }

    public playSkillAudio(e) {
        var t = "";
        if (e === SkillType.Hammer) {
            t = "hammer_use";
        } else if (e === SkillType.Arrow) {
            t = "arrow_use";
        } else if (e === SkillType.Gun) {
            t = "cannon_use";
        }
        this.playMusic(t);
    }

    public playPropSingleExplodeAni(e) {
        if (!n.skipEndGameReplacement) {
            var t = "";
            if (e === l.PropType.RocketHorzontall || e === l.PropType.RocketVertial) {
                t = "rocket_explode";
            } else if (e === l.PropType.Tnt) {
                t = "tnt_explode";
            } else if (e === l.PropType.LightingBall) {
                t = "lightball_explode";
            }
            this.playMusic(t);
        }
    }

    public playPropellerTakeOffAudio(e) {
        if (!n.skipEndGameReplacement) {
            var t;
            if (e < 0) {
                t = "propeller_take_off";
            } else if (e === l.PropType.Propeller) {
                t = "cloche_propeller_throw";
            } else {
                t = "propeller_tnt_combo";
            }
            this.playMusic(t);
        }
    }

    public playPropellerFlyAudio(e) {
        if (!n.skipEndGameReplacement) {
            var t;
            if (e < 0) {
                t = "propeller_fly";
            } else if (e === l.PropType.Tnt || e === l.PropType.RocketHorzontall || e === l.PropType.RocketVertial) {
                t = "propeller_tnt_combo";
            } else {
                t = "propeller_fly";
            }
            this.playMusic(t);
        }
    }

    public playPropellerHitAudio() {
        if (!n.skipEndGameReplacement) {
            this.playMusic("propeller_hit");
        }
    }

    public playLightBallSingleUseAudio() {
        if (!n.skipEndGameReplacement) {
            this.playMusic("lightball_start");
        }
    }

    public stopLightBallSingleUseAudio() {
        if (!n.skipEndGameReplacement) {
            this.stopMusic("lightball_start");
        }
    }

    public playLightBallRayAudio() {
        if (!n.skipEndGameReplacement) {
            this.playMusic("lightball_ray1");
        }
    }

    public playLightBallBoomAudio() {
        if (!n.skipEndGameReplacement) {
            this.playMusic("lightball_explode");
        }
    }

    public playLightBallsUseAudio() {
        if (!n.skipEndGameReplacement) {
            this.playMusic("cloche_lightball_throw");
        }
    }

    public playLightBallsBoomAudio() {
        if (!n.skipEndGameReplacement) {
            this.playMusic("lightball_lightball_combo");
        }
    }

    public playTntsUseAudio() {
        if (!n.skipEndGameReplacement) {
            this.playMusic("cloche_tnt_throw");
        }
    }

    public playTntsBoomAudio() {
        if (!n.skipEndGameReplacement) {
            this.playMusic("tnt_tnt_combo");
        }
    }

    public playRocketAndTntAudio() {
        if (!n.skipEndGameReplacement) {
            this.playMusic("rocket_tnt_combo");
        }
    }

    public playEndStepAudio1() {
        if (!n.skipEndGameReplacement) {
            this.playMusic("remaining_move_throw1");
        }
    }

    public playEndStepAudio2() {
        if (!n.skipEndGameReplacement) {
            var e = "remaining_item_land" + i.getRandomNum(1, 2);
            this.playMusic(e);
        }
    }

    public playObstacleEffectAUdio(e) {
        var t = "", a = "", o = e.Hp;
        switch (e.ObstacleAllType) {
            case ObstacleAllType.WoodenBox:
            case ObstacleAllType.ColorBox:
                t = "box_break1";
                break;

            case ObstacleAllType.Grass:
                t = "grass_clear";
                break;

            case ObstacleAllType.PurpleFlower:
                t = "bush_grass_spread";
                break;

            case ObstacleAllType.GrassLand:
                if (4 === o) {
                    t = "bush_flower_clear";
                } else if (0 === o) {
                    t = "bush_container_break";
                    a = "bush_grass_spread";
                } else {
                    t = "bush_grass_clear";
                }
                break;

            case ObstacleAllType.Egg:
                t = "egg_break1";
                break;

            case ObstacleAllType.ColorBottle:
                if (o > 0) {
                    t = "map_scroll_bottle_firststate_break_1";
                } else {
                    t = "map_scroll_bottle_firststate_break_1";
                    a = "box_break1";
                }
                break;

            case ObstacleAllType.Vase:
                t = 0 === o ? "vase_crack" : "vase_break";
                break;

            case ObstacleAllType.Honey:
                t = "honey_clear1";
                break;

            case ObstacleAllType.Icicle:
            case ObstacleAllType.curtain:
                break;

            case ObstacleAllType.Oyster:
                t = 0 === o ? "oyster_break1" : 1 === o ? "oyster_break1" : "oyster_open1a";
                break;

            case ObstacleAllType.Flowerpot:
                if (0 === o) {
                    t = "flower_break_1";
                    a = "bush_grass_spread";
                } else {
                    t = "flower_open_1";
                }
                break;

            case ObstacleAllType.Stone:
                t = 0 === o ? "rock_gem_break1" : "rock_break1";
                break;

            case ObstacleAllType.SafeBox:
                t = 4 === o ? "safe_handle_break" : 0 === o ? "safe_container_break" : "safe_door_break";
                break;

            case ObstacleAllType.cupboard:
            case ObstacleAllType.MagicHat:
            case ObstacleAllType.MailBox:
            case ObstacleAllType.Bird:
                break;

            case ObstacleAllType.GoldCoin:
                t = "coin_collect_3";
                break;

            case ObstacleAllType.PorcelainPig:
                t = "piggy_break1";
        }
        if ("" !== t) {
            this.playMusic(t);
        }
        if ("" !== a) {
            this.playMusic(a);
        }
    }

    public playIceCrusherAudio(e) {
        var t = e ? "ice_crusher_loop_end" : "ice_crusher_loop";
        this.playMusic(t);
    }

    public playIceBreakAudio() {
        this.playMusic("ice_crusher_explode");
    }

    public playCurtainCollectAudio() {
        this.playMusic("curtain_collect");
    }

    public playCurtainBreakAudio() {
        this.playMusic("curtain_chain_break");
    }

    public playCurtainDestoryAudio() {
        this.playMusic("curtain_destroy");
    }

    public playCurtainOpenAudio() {
        this.playMusic("curtain_open");
    }

    public playCupboardAudio(e) {
        var t;
        if (10 === e) {
            t = "cupboard_door_break";
        } else if (0 === e) {
            t = "cupboard_container_break";
        } else {
            t = "cupboard_plate_" + (e % 3 + 1);
        }
        this.playMusic(t);
    }

    public playMagicStateAudio(e) {
        var t = "";
        if (1 === e) {
            t = "magic_hat_state_1";
        } else if (2 === e) {
            t = "magic_hat_state_2";
        }
        this.playMusic(t);
    }

    public playMagicWhooshAudio() {
        this.playMusic("magic_hat_whoosh_1");
    }

    public playMagicCloseAudio() {
        this.playMusic("magic_hat_close");
    }

    public playMagicGemLandAudio() {
        this.playMusic("magic_hat_gem_land");
    }

    public playMailExitAudio() {
        this.playMusic("mail_exit");
    }

    public playMailCloseAudio() {
        r.log("播放mailbox_close");
        this.playMusicSingle("mailbox_close");
    }

    public playBirdCollectAudio() {
        this.playMusic("bird_collect_1");
    }

    public playTargetFinishAudio() {
        this.playMusic("hbResult_2");
    }

    public playSuccessPageShowAudio() {
        this.playMusic("hbResultFly");
    }

    public playFailShowAudio() {
        this.playMusic("ego_enter");
    }

    public playFailExitAudio() {
        this.playMusic("level_failed");
    }

    public playFailAddStepAudio() {
        this.playMusic("ego_buy");
    }

    public playNoStepShowAudio() {
        this.playMusic("out_of_moves_enter");
    }

    public playNoStepExitAudio() {
        this.playMusic("out_of_moves_exit");
    }

    public playOneTargetFinishAudio() {
        this.playMusic("goal_complete");
    }

    public playEnterUIAudio() {
        this.playMusic("level_enter_ui");
    }

    public playEnterBoardAudio() {
        this.playMusic("level_enter_board");
    }

    public playCoinGuideAudio() {
        this.playMusic("matchgame_guide_coin");
    }

    public stopCoinGuideAudio() {
        this.stopMusic("matchgame_guide_coin");
    }

    public playCoinTargetToRedPackAudio() {
        this.playMusic("mail_exit");
    }

    public playMailBoxCloseAudio() {
        r.log("播放mailbox_close");
        this.playMusicSingle("mailbox_close");
    }

    public playCandleBoxShakeAudio() {
        this.playMusic("dynamite_box_shake_1");
    }

    public playCandleBoxShake2Audio() {
        this.playMusic("dynamite_box_in_1");
    }

    public playCandleBlipAudio() {
        this.playMusic("dynamite_box_blip");
    }

    public playCandleFuseAudio() {
        this.playMusic("dynamite_box_fuse");
    }

    public playCandleExplodeAudio() {
        this.playMusic("dynamite_box_explode");
    }

    public playCupBreakAudio() {
        this.playMusic("cup_break1");
    }

    public playCupHolderBreakAudio() {
        this.playMusic("shelf_break1");
    }

    public playRockBreakAudio(e) {
        var t = "";
        if (1 === e) {
            t = "rock_break1";
        } else if (2 === e) {
            t = "rock_gem_break1";
        }
        this.playMusic(t);
    }

    public playBirdNestAudio(e) {
        var t = "";
        switch (e) {
            case 1:
                t = "bird_nest_door";
                break;

            case 2:
                t = "bird_nest_wall_1";
                break;

            case 3:
            case 4:
                t = "bird_nest_egg_1";
                break;

            case 5:
                t = "bird_nest_destroy_1";
        }
        if (t) {
            this.playMusic(t);
        }
    }

    public playBirdFly() {
        this.playMusic("bird_nest_throw_1");
    }

    public playBirdFall() {
        this.playMusic("bird_nest_land");
    }
}

const instance = MatchGameAudioMgr.getInstance();
export default instance;